/* 
 //
 */
var API = location.href;

function mfun() {///
    /*   $('[xz=int]').on("keyup",function(){
     this.value=this.value.replace(/\D/g,'');
     });
     */
    $('[xz=int]').keypress(function () {
        return (/[\d.]/.test(String.fromCharCode(event.keyCode)));
    });


    $(".body_height").css("height", window.screen.availHeight + "px");
    $("[lhref]").click(function () {
        var str = $(this).attr("lhref");
        location.href = str;
    });
}
;

$(document).ready(function () {
    L.init();
    mfun();
//     m.ready();
    /*
     
     */
//quanxuan();

    if ($('[time=time]')[0])
        $('[time=time]').datetimepicker({
            timeFormat: "HH:mm:ss",
            dateFormat: "yy-mm-dd"
        });

});
var L = new function () {

    this.select = function (tclass) {
        var li = $(tclass + " .ace[gid]:checked");
        var len = li.length;
        if (len === 0) {
            return "";
        }
        var slist = new Array();
        for (var i = 0; i < len; i++) {
            slist.push($(li[i]).attr("gid"));
        }
        var str = slist.join(",");
        return str;
    };






    this.onenter = function (k) {
        if (k.keyCode !== 13)
            return;
        var jstr = $(this).attr("onenter");
        eval(jstr);
    };
    this.msg = function (t) {
        artDialog.tips(t);
    };
    this.Dlg = function (t) {
        art.dialog({
            content: t,
            ok: true
        });
    };

    this.init = function () {

        $("[onenter]").keyup(L.onenter);

        artDialog.tips = function (content, time) {
            return artDialog({
                id: 'Tips',
                title: false,
                cancel: false,
                fixed: true,
                lock: false
            })
                    .content('<div style="padding: 0 1em;">' + content + '</div>')
                    .time(time || 1.5);
        };
        m.ready();
    };




    this.p = function (u, c, f) {
        if (typeof (f) !== "function")
        {
            var fun = function (d)
            {
                if (d.error === 0)
                    L.msg(d.msg);
                else
                    L.Dlg(d.msg);
            };
        }
        else
        {
            var fun = f;
        }
        c.p_type = u;
        $.post(API, c, fun, "json");
    };
};







function delete_cache() {
    $.post("/index.php/admin/view/delete_cache", {}, function () {
        m.tishi('缓存已经清除');
    });
}


var m = new function () {
    this.ready = function () {

        if (!$("#ShowMessageBox_msg")[0])
            return;
        var msg = eval($("#ShowMessageBox_msg").val());
        if (msg.type == 'tishi') {
            m.tishi(msg.text);
        }
        if (msg.type == 'xunwen') {
            m.xunwen(msg.text);
        }
    };
    this.tishi = function (text) {
        artDialog.tips(text);
    };
    this.xunwen = function (text, ok_fun) {
        if (typeof (ok_fun) !== 'function') {
            ok_fun = function () {
                return true;
            };
        }
        art.dialog({
            content: text,
            ok: ok_fun,
            cancel: true
        });
    };





};


var sh = new function () {
    /**
 * 分享成功的回调
 */
    this.OnFenxiang=function(){
       // alert('ddddddd');
    };
 
    this.isnewwin=false;
 
    this.open = function (str) { 
        
        if(sh.isnewwin){
            window.open(str);return;
        }
            window.open(str, "_self");
      
    };

    /**
     * 人人
     */
    this.renren = function () {
      
        sh.open('http://widget.renren.com/dialog/share?title=' 
                + encodeURIComponent(share.weibo)
                + '&description=' + encodeURIComponent(share.desc)
                + '&resourceUrl=' + encodeURIComponent(share.url) + '&srcUrl=' + encodeURIComponent(share.url)

                + '&pic=' + share.img
                );
    };


    /**
     * 分享微博
     */
    this.weibo = function () { 
        sh.open('http://v.t.sina.com.cn/share/share.php?title=' + encodeURIComponent(share.weibo)
                + '&url=' + encodeURIComponent(share.url) +
                '&pic=' +  share.img
                );
    };

    /**
     * 豆瓣
     */
    this.douban = function () { 
        sh.open('http://www.douban.com/share/service?title=' + encodeURIComponent(share.weibo)
                + '&name=' + encodeURIComponent(share.desc)
                + '&href=' + encodeURIComponent(share.url)
                + '&image=' + encodeURIComponent( share.img)
                );
    };
    /**
     * 分享到QQ空间
     */
    this.shareQQ=function(){
        sh.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='
                +encodeURIComponent(share.url)
                +'&summary='+encodeURIComponent(share.desc)
                +'&title='+encodeURIComponent(share.weibo)
                +'&pics='+encodeURIComponent(share.img)
                );
    };
     
     
     /**
      * 关闭分享窗口
      */
     this.close=function(){
         $('#share_content,.share_beijing').hide();
     };
 
     /**
      * 用户点击了分享按钮
      */
     this.fenxiang=function(){
         if(share.get_type===''){
             sh.open_qitaWin();
             return ;
         }
         if(share.get_type=='weixin'||share.get_type=='yixin'){
             sh.show_share_div();
             return ;
         }
         if(share.get_type==='music'){///云音乐环境分享接口
             h.fenxiang();return;
         }
         
     };
     
     /**
      * 打开其它环境的分享窗口
      */
     this.open_qitaWin=function(){
         $('#share_content,.share_beijing').show();
     };
 
     /**
      * 显示分享层
      */
     this.show_share_div=function(){
         $('.share_wx').show();
     };
     
     /**
      * 关闭分享层
      */
     this.share_wx_close=function(){
         $('.share_wx').hide();
     };
     
     
     /**
      * 分享为到微信
      */
     this.share_weixin=function(){
         sh.show_erweima();
       
     };
     /**
      * 易信
      */
     this.share_yixin=function(){
         sh.show_erweima();
     };
     /**
      * 显示二维码
      */
     this.show_erweima=function(){
         sh.showmsg_fun('<img src="/phpqrcode?u='+encodeURIComponent(share.url)+'" width="100" class="shareerweima" />');
     };
 
 this.share_txweibo=function(){
     var url='http://share.v.t.qq.com/index.php?c=share&a=index&title='+encodeURIComponent(share.weibo)+'&url='+encodeURIComponent(share.url)+
             '&pic='+encodeURIComponent(share.img);
     sh.open(url);
 };

  this.share_Kongjian=function(){
     
 };
 
 
 
    /**
     * 指定分享内容和类型
     */
    this.urlshare=function(type,title,desc,img,url){
        if(title==''){
            title=share.title;
        }
        if(desc==''){
            desc=share.desc;
        }
        if(img==''){
            img=share.img;
        }
        if(url==''){
            url=share.url;
        }
        var data={
            title:title,
            url:url,
            img:img,
            desc:desc
        };
        if(type=='sina'){
            sh.open('http://v.t.sina.com.cn/share/share.php?title=' + encodeURIComponent(data.title)
                + '&url=' + encodeURIComponent(data.url) +
                '&pic=' +  data.img
                );
        return;
        }
        
        if(type=='renren'){
              sh.open('http://widget.renren.com/dialog/share?title=' 
                + encodeURIComponent(data.title)
                + '&description=' + encodeURIComponent(data.desc)
                + '&resourceUrl=' + encodeURIComponent(data.url) + '&srcUrl=' + encodeURIComponent(data.url)
                + '&pic=' + data.img
                );
        return;
        }
        
        
             
      
    };
    
    
    
    
    
    
    
};

//var sys = null;
var sys = new function () {
    
     /**
     * 加载js文件
     */
    this.loadJS = function (jsUrl,fun) {$.getScript(jsUrl,fun);
    };
    /**
     * 加载css文件
     */
    this.loadCSS=function(path){
        if(!path || path.length === 0){
			throw new Error('argument "path" is required !');
		}
		var head = document.getElementsByTagName('head')[0];
        var link = document.createElement('link');
        link.href = path;
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link);
    };
    
var clickname=new Array();
    /**
     * 防止用户短时间内多次点击按钮
     */
    this.isclick=function(na){
        if(typeof(na)=='undefined'){
            na=0;
        }
        if(typeof(clickname[na])!=='undefined'&&clickname[na]){
            return true;
        }
        clickname[na]=true;
        setTimeout(function(){
            clickname[na]=false;
        },900);
        return false;
    };
//function H_FUN() {
    this.post = function (url, par, fun, msg) {
        if (typeof (msg) != 'string' || msg == '') {
            msg = "操作成功";
        }
        if (typeof (fun) != 'function') {
            fun = function (data) {
                //  alert(msg);
            };
        }

        if (typeof (WEB) == 'string'&&url[0]!=='/') {
            url = WEB + url;
        }

        if ($('[name=csrf-token]')[0]) {
            if (typeof (par) === 'undefined')
                par = {};
            par['_csrf'] = $('[name=csrf-token]').attr('content');
        }


        $.post(url, par, function (data) {
            if (data.code != 0) {
                if (data.code == 2) {
                    sys.login();
                    return;
                }
                alert(data.msg);
                return;
            } else {
                fun(data);
            }
        }, 'json');
    };

   
}
;


function clear_errorlog() {
    sys.post(clear_api, {});
}
















/**
 * 以下是项目的
 */
$(function () {
    $('.albumbutton').click(function () {
        var bvl = $(this);
        var id = bvl.attr('bid');
        var obj = $('#' + id);
        var value = obj.val();

    });
});





























